import { maintenanceHttp } from '/@/utils/http/axios';
import { BasicFetchResult } from '/@/api/model/baseModel';
import { AppPurchasesItem, BasicDataItem, instanceProportinItem, RegisterUserItem } from '/@/api/homepage/model/homepageModel';

enum Api {
  GET_BASIC_DATA = '/v1/maintenance/frontPage/basicData',
  GET_SOLD_APPS = '/v1/maintenance/frontPage/getSoldApps',
  GET_APP_PURCHASES = '/v1/maintenance/frontPage/getAppPurchases',
  GET_PAID_TENANTS = '/v1/maintenance/frontPage/getPaidTenants',
  GET_ONLINE_USERS = '/v1/maintenance/frontPage/onlineUsers',
  GET_SUBSCRIBED_APPS = '/v1/maintenance/frontPage/getSubscribedApps',
  GET_MONTHLY_REGISTER_USERS = '/v1/maintenance/frontPage/monthlyRegisteredUsers',
  GET_PACKAGE_PROPORTION = '/v1/maintenance/frontPage/packageProportion',
}

export const getBasicData = () => {
  return maintenanceHttp.get<BasicDataItem>({ url: Api.GET_BASIC_DATA });
};
export const getSoldApps = () => {
  return maintenanceHttp.get<string>({ url: Api.GET_SOLD_APPS });
};

export const getPaidTenants = () => {
  return maintenanceHttp.get<string>({ url: Api.GET_PAID_TENANTS });
};

export const getAppPurchases = () => {
  return maintenanceHttp.get<AppPurchasesItem[]>({
    url: Api.GET_APP_PURCHASES,
  });
};

export const getSubscribedApps = () => {
  return maintenanceHttp.get<string>({ url: Api.GET_SUBSCRIBED_APPS });
};

export const getOnlineUsers = () => {
  return maintenanceHttp.get<BasicFetchResult<string>>({
    url: Api.GET_ONLINE_USERS,
  });
};

export const getMonthlyRegisterMap = () => {
  return maintenanceHttp.get<RegisterUserItem>({
    url: Api.GET_MONTHLY_REGISTER_USERS,
  });
};

export const getPackageProportion = () => {
  return maintenanceHttp.get<instanceProportinItem>({
    url: Api.GET_PACKAGE_PROPORTION,
  });
};
